<?php
session_start();
require_once 'include/db.php';
require_once 'include/userClass.php';
require_once 'include/adminClass.php';
require_once 'include/functions.php';

$title="Administrator statisikk";
include 'include/header.php';

if($user -> userLoggedOn() && $user->isUserAdmin()) {
    echo "<div id='content'>";
    if(isset($_GET['newAdmin']) && $_GET['newAdmin']!="") {
        $action = $admin->setNewAdmin($_GET['newAdmin']);
    }
	echo "<h2>Velg bruker å gjøre til admin</h2>";
	if(isset($action)) {
		echo "<h4>$action</h4>";
	}
	echo "<form id='adminform' name='newadminform' action='newAdmin.php' method='get'>\n
			<input type='hidden' name='usrName' value='".$_GET['usrName']."' />
				<select name='newAdmin'>";
				getUserList($db);
	echo		"</select>
            <input type='submit' value='Gjør til administrator'>
        </form>";
    
    echo"</div>\n
    <div id='side'>";
        $user -> showUserInfo($user -> getUserInfo(NULL));
        echo "<a class='button' href='adminStat.php?usrName=".$user->userName."' title='Statistikk'>Brukeroversikt</a><br/>\n
			<a class='button' href='newAdmin.php?usrName=".$user->userName."' title='Ny admin'>Ny administrator</a><br/>
			<a class='button' href='displayUsr.php?usrName=".$user->userName."&own=true' title='Min blogg'>Min blogg</a><br/>
            <a class='button' href='newPost.php?usrName=".$user->userName."' title='Nytt innlegg'><img class='icon' src='include/img/Edit.png' />Nytt innlegg</a><br/>\n
			<a class='button' href='editUser.php' title='Rediger profil'><img class='icon' src='include/img/Wheel.png' />Rediger profil</a>";
    echo "</div>";
}
else { ?>
    <div id="content">
        <h2>Oooops!</h2>
        <p>Du har ikke tilgang på denne siden...</p>
    </div>
<?php }

include 'include/footer.php';

?>